<template>
  <view>
    <!-- 支付方式选择 -->
    <radio-group class="payment-method" @change="handlePaymentChange" v-for="(item, index) in payList" :key="index">
      <label class="payment-item">
        <view class="payment-left">
          <uni-icons :type="item.type" size="20" :color="item.color"></uni-icons>
          <text>{{item.title}}</text>
        </view>
        <radio :value="item.type" :checked="paymentMethod === item.type" :color="item.color" />
      </label>
    </radio-group>
  </view>
</template>

<script>
  export default {
    name: "PaymentMethod",
    props: {
      payList: Array
    },
    data() {
      return {
        paymentMethod: 'wechat'
      };
    },
    methods: {
      handlePaymentChange(e) {
        this.paymentMethod = e.detail.value
      },
    }
  }
</script>

<style lang="scss" scoped>
  .payment-method {
    margin: 10px 0;
    background-color: #fff;
  }

  .payment-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #f5f5f5;
  }

  .payment-left {
    display: flex;
    align-items: center;

    text {
      margin-left: 10px;
    }
  }
</style>